Page({
  /**
   * 页面的初始数据
   */
  data: {
    pageNum: 1,
    // 搜索
    serach_pro: "",
    prosum: null,
    prolist: [],
    loading: true
  },
  // 搜索
  serachProChange (e) {
    this.setData({
      prolist: [],
      serach_pro: e.detail,
    });
  },

  goOnChange (e) {
    this.setData({
      serach_pro: e.detail,
    });
  },

  goSearch () {
    this.setData({
      prolist: [],
      prosum: '',
      pageNum: 1
    });
    this.getList();
  },
  toprodetail (e) {
    console.log(e.detail, 'e.detail')
    if (e.detail.totalscore || e.detail.totalscore == 0) {
      wx.navigateTo({
        url: "/packageA/pages/homelink/measure_limit_detail/measure_limit_detail?corpKey=" + e.detail.corpKey,
      });
    } else {
      wx.showModal({
        title: '提示',
        content: '该企业尚未进行地方征信平台授权，请提交授权书后使用测额度功能。',
        showCancel: false,
        confirmText: '确定',
        success: function () {}
      })
    }
  },
  phone (event) {
    wx.makePhoneCall({
      phoneNumber: event.currentTarget.id,
    });
  },
  location (event) {
    var _this = this;
    wx.openLocation({
      latitude: _this.data.prolist[event.currentTarget.id].latitude,
      longitude: _this.data.prolist[event.currentTarget.id].longitude,
      name: _this.data.prolist[event.currentTarget.id].d2CorpName,
      address: _this.data.prolist[event.currentTarget.id].d2Dom,
      scale: 18,
    });
  },
  // 滑动底部加载更多
  scrollBottom () {
    this.onBottom();
  },
  getList () {
    var _this = this;
    this.setData({
      loading: true,
    })
    wx.showLoading({
      title: "加载中",
    });
    // const params = {
    //   pageSize: 50,
    //   pageNum: this.data.pageNum,
    //   keyword: _this.data.serach_pro,
    // };
    const params = {
      pageBO: {
        pageSize: 50,
        pageNum: this.data.pageNum,
      },
      searchParam: _this.data.serach_pro,
    };
    console.log(params, "params");
    getApp()
      .globalData.request("/map/fullAmountCorp", params, "POST")
      .then((res) => {
        setTimeout(function () {
          wx.hideLoading();
        }, 500);
        var rstObj = res;
        console.log(res, "res");
        if (rstObj.data) {
          _this.setData({
            prolist: this.data.prolist.concat(rstObj.data.list),
            prosum: rstObj.data.total,
          });
          this.setData({
            loading: false,
          })
        }
      });
  },

  onBottom () {
    if (this.data.prolist.length >= this.data.prosum) return
    this.data.pageNum++;
    this.getList();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad (options) {
    console.log(options.searchvalue);
    this.setData({
      serach_pro: options.searchvalue
    })
    this.getList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady () { },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow () { },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide () { },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload () { },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh () { },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom () { },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage () { },
});